<?php

session_start();
include '../database/connect.php';
$tbl_name = "students_login";
$username = $_POST['username'];
$password = $_POST['password'];
$phone_number = $_POST['phone_number'];
$confirm_password = $_POST['confirm_password'];
$queryuser = mysql_query("SELECT * FROM $tbl_name WHERE username='$username' ");
$checkuser = mysql_num_rows($queryuser);
if ($checkuser != 0) {
    header("location:../views/signup.php?status=wrongu");
} else {
    if ($password != $confirm_password) {
        header("location:../views/signup.php?status=wrongp");
    } else {
        $insert_user = mysql_query("INSERT INTO $tbl_name (username,phone_number, password) VALUES ('$username','$phone_number', '$password')");
        if ($insert_user == True) {
            header("location:../views/login.php?status=saved");
        } else {
            header("location:../views/signup.php?status=wrong");
        }
    }
}
?>